package request

import (
	"game-server/app/models"
)

type GameListRequest struct {
	Name              string `json:"name" form:"name"`                                                         // 游戏名称
	CategoryID        *uint  `json:"category_id" form:"category_id"`                                           // 分类ID
	Status            *int   `json:"status" form:"status"`                                                     // 状态
	StartTime         string `json:"start_time" form:"start_time"`                                             // 开始时间
	EndTime           string `json:"end_time" form:"end_time"`                                                 // 结束时间
	IsNewHotRecommend *int   `json:"is_new_hot_recommend" form:"is_new_hot_recommend" binding:"oneof=0 1 2 3"` // 1:新游戏 2:热门 3:推荐
	//标签ID
	TagsID uint `json:"tags_id" form:"tags_id"`
	//tagsID

	Page     int `json:"page" form:"page" binding:"required,gte=1"`
	PageSize int `json:"page_size" form:"page_size" binding:"required,gte=1,lte=100"`
}

func (gameListRequest GameListRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"page.required":      "页码不能为空",
		"page.gte":           "页码不能小于1",
		"page_size.required": "每页条数不能为空",
		"page_size.gte":      "每页条数不能小于1",
		"page_size.lte":      "每页条数不能大于100",
	}
}

// @Description 游戏添加请求
type GameAddRequest struct {
	Name        string                     `json:"name" binding:"required,min=2,max=50" label:"游戏名称"`
	Icon        string                     `json:"icon" binding:"required" label:"游戏图标"`
	GameUrl     string                     `json:"game_url" binding:"required" label:"游戏链接"`
	Desc        string                     `json:"desc" label:"游戏描述"`
	Image       string                     `json:"image" binding:"required" label:"游戏图片"`
	Introduce   string                     `json:"introduce"  label:"游戏介绍"`
	Width       int                        `json:"width" label:"游戏宽度"`
	Height      int                        `json:"height" label:"游戏高度"`
	Status      int                        `json:"status" binding:"oneof=0 1" label:"状态"`
	CategoryId  uint                       `json:"category_id"  label:"分类ID"`
	IsNew       int                        `json:"is_new" binding:"oneof=0 1" label:"是否新游戏"`
	IsHot       int                        `json:"is_hot" binding:"oneof=0 1" label:"是否热门游戏"`
	IsRecommend int                        `json:"is_recommend" binding:"oneof=0 1" label:"是否推荐游戏"`
	Sort        int                        `json:"sort"  label:"排序"`
	Tags        []models.TagRequest        `json:"tags"   label:"标签"`
	Click       int                        `json:"click"  label:"点击量"`
	ScreenShots []models.ScreenShotRequest `json:"screen_shots"   label:"游戏截图"`
	GameVideos  []models.GameVideoRequest  `json:"game_videos"    label:"游戏视频"`
}

func (gameAddRequest GameAddRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"name.required":     "游戏名称不能为空",
		"name.min":          "游戏名称长度不能小于2",
		"name.max":          "游戏名称长度不能大于50",
		"icon.required":     "游戏图标不能为空",
		"game_url.required": "游戏链接不能为空",
	}
}

type GameUpdateRequest struct {
	ID          uint                `json:"id" binding:"required" label:"游戏ID"`
	Name        string              `json:"name" binding:"required,min=2,max=50" label:"游戏名称"`
	Icon        string              `json:"icon" binding:"required" label:"游戏图标"`
	GameUrl     string              `json:"game_url" binding:"required" label:"游戏链接"`
	Desc        string              `json:"desc" label:"游戏描述"`
	Image       string              `json:"image" binding:"required" label:"游戏图片"`
	Introduce   string              `json:"introduce" label:"游戏介绍"`
	Width       int                 `json:"width" label:"游戏宽度"`
	Height      int                 `json:"height" label:"游戏高度"`
	Status      int                 `json:"status" binding:"oneof=0 1" label:"状态"`
	CategoryId  uint                `json:"category_id" binding:"required" label:"分类ID"`
	IsNew       int                 `json:"is_new" binding:"oneof=0 1" label:"是否新游戏"`
	IsHot       int                 `json:"is_hot" binding:"oneof=0 1" label:"是否热门游戏"`
	IsRecommend int                 `json:"is_recommend" binding:"oneof=0 1" label:"是否推荐游戏"`
	Sort        int                 `json:"sort" label:"排序"`
	Tags        []models.Tag        `json:"tags" swaggertype:"array,object"  label:"标签"`
	ScreenShots []models.ScreenShot `json:"screen_shots" swaggertype:"array,object"  label:"游戏截图"`
	GameVideos  []models.GameVideo  `json:"game_videos" swaggertype:"array,object"  label:"游戏视频"`
}

type GameBatchDelRequest struct {
	IDS []uint `json:"ids" binding:"required" label:"游戏ID"`
}

func (gameBatchDelRequest GameBatchDelRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"ids.required": "游戏ID不能为空",
	}
}

func (gameUpdateRequest GameUpdateRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"id.required": "游戏ID不能为空",
		"name.min":    "游戏名称长度不能小于2",
		"name.max":    "游戏名称长度不能大于50",
	}
}

type GameDelRequest struct {
	ID uint `json:"id" binding:"required" label:"游戏ID"`
}

func (gameDelRequest GameDelRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"id.required": "游戏ID不能为空",
	}
}

type GameClickRequest struct {
	ID uint `json:"id" binding:"required" label:"游戏ID"`
}

func (gameClickRequest GameClickRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"id.required": "游戏ID不能为空",
	}
}

// GameDetailRequest 游戏详情请求
type GameDetailRequest struct {
	ID uint `json:"id" binding:"required" label:"游戏ID"`
}

func (gameDetailRequest GameDetailRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"id.required": "游戏ID不能为空",
	}
}
